package org.xg.study.pd.test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xg.study.pd.AwardReq;
import org.xg.study.pd.AwardRes;
import org.xg.study.pd.PrizeController;

import java.util.HashMap;

/**
 * @author CMG
 * @version 1.0
 * @cLassName ApiTest
 * @description
 * @date 2021/9/9 9:14
 **/
public class ApiTest1_01 {
    private Logger log = LoggerFactory.getLogger(ApiTest1_01.class);

    @Test
    public void test_awardToUser(){
        PrizeController prizeController = new PrizeController();
        System.out.println("\r\n模拟发放优惠券测试\r\n");
        //模拟方法优惠券测试
        AwardReq awardReq = new AwardReq();
        awardReq.setuId("10001");
        awardReq.setAwardType(1);
        awardReq.setAwardNumber("EGM1023938910232121323432");
        awardReq.setBizId("791098764902132");
        AwardRes awardRes = prizeController.awardToUser(awardReq);
        log.info("请求参数：{}", JSONObject.toJSON(awardReq));
        log.info("测试结果：{}", JSONObject.toJSON(awardRes));

        System.out.println("\r\n模拟发放实物商品\r\n");
        //模拟实物商品
        AwardReq awardReq1 = new AwardReq();
        awardReq1.setuId("10001");
        awardReq1.setAwardType(2);
        awardReq1.setAwardNumber("9820198721311");
        awardReq1.setBizId("1023000020112221113");
        awardReq1.setExtMap(new HashMap<String, String>(){{
            put("consigneeUserName","谢飞机");
            put("consigneeUserPhone","15200292123");
            put("consigneeUserAddress","吉林省.长春市.双阳区.XX街道.檀溪苑小区.#18-2109");
        }});
        AwardRes awardRes1 = prizeController.awardToUser(awardReq1);
        log.info("请求参数：{}", JSONObject.toJSON(awardReq1));
        log.info("测试结果：{}", JSONObject.toJSON(awardRes1));

        System.out.println("\r\n模拟发放第三方兑换卡(爱奇艺)\r\n");
        //模拟第三方兑换卡（爱奇艺）
        AwardReq awardReq2 = new AwardReq();
        awardReq2.setuId("10001");
        awardReq2.setAwardType(3);
        awardReq2.setAwardNumber("AQY1xjkUodl8LO975GdfrYUio");
        AwardRes awardRes2 = prizeController.awardToUser(awardReq2);
        log.info("请求参数：{}", JSON.toJSON(awardReq2));
        log.info("测试结果：{}", JSON.toJSON(awardRes2));
    }
}
